package com.marsproj.bankingmanagesystem.dao;

import com.marsproj.bankingmanagesystem.entity.Account;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Repository
@Mapper
public interface AccountDao {

    // 新增账户
    @Insert("insert into account (uid, name, money, createTime, remark) values (#{uid}, #{name},#{money},#{createTime},#{remark})")
    int addAccount(Account account);

    // 查全部余额信息
    @Select("select uid,name,money from account")
    List<Map> queryAll();

    // 查特定账户余额信息
    @Select("select money from account where uid = #{uid}")
    BigDecimal queryOne(String uid);

    // 修改余额
    @Update("update account set money = #{money} where uid = #{uid}")
    int handleDeal(BigDecimal money,String uid);

}
